
/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  August 10th 2009 1:10:39 PM PDT                              */
/*      Machine:  10.16.140.110                                                */
/*       Source:  Backing Store                                                */
/*     Location:  js/7xgoudrrqhgc40go.pkg.js h:79f76leq                        */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/7xgoudrrqhgc40go.pkg.js                                   */
function ScrollArea(scroll_div_id, content_div_id, down_arrow_id, up_arrow_id) {
	if (this === window) {
		Util.error("You're doing this wrong.  This is a class and should be " + "with new ScrollArea(...);");
		return;
	}
	copy_properties(this, {scroll_div:$(scroll_div_id), content_div:$(content_div_id), down_arrow:$(down_arrow_id), up_arrow:$(up_arrow_id)});
	copy_properties(this, {auto_move_interval:null, allow_page_scroll:true, max_height:false});
	this.down_arrow.onmouseout = bind(this, "_endAutoMove", ScrollArea.DOWN);
	this.down_arrow.onmouseover = bind(this, "_startAutoMove", ScrollArea.HOVER_INTERVAL, ScrollArea.DOWN);
	this.up_arrow.onmouseout = bind(this, "_endAutoMove", ScrollArea.UP);
	this.up_arrow.onmouseover = bind(this, "_startAutoMove", ScrollArea.HOVER_INTERVAL, ScrollArea.UP);
	this.scroll_div.onmouseover = bind(this, "_disallowPageScroll");
	this.scroll_div.onmouseout = bind(this, "_allowPageScroll");
	ScrollWheel.addHandler(this._pageScrollResponse.bind(this));
	ScrollArea.instances.push(this);
	this.update();
}
copy_properties(ScrollArea, {HOVER_INTERVAL:50, MOUSE_WHEEL_MULTIPLE:-8, UP:1, DOWN:2, instances:[], build:function (id, content, max_height) {
	var content_id = id + "_content";
	var scroll_id = id + "_scroll";
	var down_id = id + "_down";
	var up_id = id + "_up";
	var content_node = $N("div", {"className":"scroll_area_content", "id":content_id}, content);
	var down_node = $N("a", {"className":"arrow down_arrow", "id":down_id}, HTML("<span>&nbsp;</span>"));
	down_node.listen("click", Event.kill);
	var up_node = $N("a", {"className":"arrow up_arrow", "id":up_id}, HTML("<span>&nbsp;</span>"));
	up_node.listen("click", Event.kill);
	var scroller_node = $N("div", {"className":"scroll_area_scroll", "id":scroll_id});
	scroller_node.appendChild(content_node);
	scroller_node.appendChild(down_node);
	scroller_node.appendChild(up_node);
	var wrapper_node = $N("div", {"id":id}, scroller_node);
	(function (scroll_id, content_id, down_id, up_id, max_height) {
		new ScrollArea(scroll_id, content_id, down_id, up_id).setMaxHeight(max_height);
	}).bind(this, scroll_id, content_id, down_id, up_id, max_height).defer();
	return wrapper_node;
}, getInnerInstance:function (element) {
	for (var i = 0; i < ScrollArea.instances.length; i++) {
		if (DOM.contains(element, ScrollArea.instances[i].scroll_div)) {
			return ScrollArea.instances[i];
		}
	}
	return false;
}});
copy_properties(ScrollArea.prototype, {_startAutoMove:function (interval_time, direction) {
	if (direction == ScrollArea.UP) {
		this.up_arrow.addClass("arrow_hover");
		this.up_arrow.addClass("up_arrow_hover");
	} else {
		this.down_arrow.addClass("arrow_hover");
		this.down_arrow.addClass("down_arrow_hover");
	}
	var move_fn = bind(this, this.moveBy, (direction == ScrollArea.UP) ? -11 : 11);
	this.auto_move_interval = setInterval(move_fn, interval_time);
}, _endAutoMove:function (direction) {
	if (direction == ScrollArea.UP) {
		this.up_arrow.removeClass("arrow_hover");
		this.up_arrow.removeClass("up_arrow_hover");
	} else {
		this.down_arrow.removeClass("arrow_hover");
		this.down_arrow.removeClass("down_arrow_hover");
	}
	clearInterval(this.auto_move_interval);
}, _disallowPageScroll:function () {
	this.allow_page_scroll = false;
}, _allowPageScroll:function () {
	this.allow_page_scroll = true;
}, _pageScrollResponse:function (delta) {
	if (!this.allow_page_scroll) {
		var round_fn = delta > 0 ? Math.ceil : Math.floor;
		this.moveBy(ScrollArea.MOUSE_WHEEL_MULTIPLE * round_fn(delta));
	}
	return this.allow_page_scroll;
}, _scrollTop:function () {
	return (-1 * parseInt(this.content_div.style.marginTop)) || 0;
}, _setScrollTop:function (new_top) {
	new_top = this._enforceRange(new_top);
	this.content_div.style.marginTop = -new_top + "px";
}, _isAtTop:function () {
	return this._scrollTop() == 0;
}, _isAtBottom:function () {
	var scrollTop = this._scrollTop();
	return scrollTop == this._enforceRange(scrollTop + 1);
}, _enforceRange:function (test_val) {
	var new_top;
	var hidden_content_height = Vector2.getElementDimensions(this.content_div).y - Vector2.getElementDimensions(this.scroll_div).y;
	if (test_val < 0) {
		new_top = 0;
	} else {
		if (test_val > hidden_content_height) {
			new_top = hidden_content_height;
		} else {
			new_top = test_val;
		}
	}
	return new_top;
}, setMaxHeight:function (new_max) {
	this.max_height = new_max;
	return this;
}, moveBy:function (distance) {
	var current_top = this._scrollTop();
	var new_top = current_top + distance;
	this._setScrollTop(new_top);
	this.update();
	return this;
}, moveTo:function (destination) {
	this._setScrollTop(destination);
	this.update();
	return this;
}, update:function () {
	var content_size = Vector2.getElementDimensions(this.content_div);
	var scroll_size = Vector2.getElementDimensions(this.scroll_div);
	if (content_size.y) {
		if (content_size.y >= this.max_height && scroll_size.y != this.max_height) {
			this.scroll_div.style.height = this.max_height + "px";
		} else {
			if (content_size.y < this.max_height && scroll_size.y != content_size.y) {
				this.scroll_div.style.height = content_size.y + "px";
			}
		}
	}
	this._isAtTop() ? CSS.addClass(this.scroll_div, "at_top") : CSS.removeClass(this.scroll_div, "at_top");
	this._isAtBottom() ? CSS.addClass(this.scroll_div, "at_bottom") : CSS.removeClass(this.scroll_div, "at_bottom");
	return this;
}});
ScrollWheel = function () {
	var _listenerAttached = false;
	var _callbacks = [];
	var _handle = function (event) {
		var delta = 0;
		event = $E(event);
		if (event.wheelDelta) {
			delta = event.wheelDelta / 120;
			if (ua.opera()) {
				delta = -delta;
			}
		} else {
			if (event.detail) {
				delta = -event.detail / 3;
			}
		}
		if (delta) {
			for (var i = 0; i < _callbacks.length; i++) {
				if (!_callbacks[i](delta)) {
					Event.kill(event);
					return;
				}
			}
		}
	};
	return {addHandler:function (callback) {
		if (!_listenerAttached) {
			if (window.addEventListener) {
				window.addEventListener("DOMMouseScroll", _handle, false);
			}
			window.onmousewheel = document.onmousewheel = _handle;
			_listenerAttached = true;
		}
		_callbacks.push(callback);
	}};
}();
function StatusEditor(root, profile_id) {
	this.rootElem = root;
	this.profile_id = profile_id;
	this.statusInput = DOM.find(root, "input.status_input");
	this.placeholder = this.getPlaceholder();
	this.emptyValue = this.statusInput.value;
	this.initialValue = "";
	this.location_id = false;
	this.locationEnabled = false;
	this._attach();
	var ix = StatusEditor.instances.push(this) - 1;
	onunloadRegister(function () {
		delete StatusEditor.instances[ix];
	});
}
StatusEditor.instances = [];
StatusEditor.update = function (payload, time, initiator) {
	StatusEditor.instances.forEach(function (editor) {
		if (editor != initiator) {
			editor._onUpdate(payload, time);
		}
	});
};
StatusEditor.poll = function () {
	new AsyncRequest().setURI("/ajax/poll_status.php").setMethod("GET").setReadOnly(true).setOption("bundle", true).setHandler(function (r) {
		var payload = r.getPayload();
		StatusEditor.update(payload, null);
	}).send();
};
StatusEditor.prototype._onUpdate = bagofholding;
StatusEditor.prototype.getPlaceholder = function () {
	var placeholder = DOM.find(this.rootElem, "input.status_placeholder_input");
	return placeholder;
};
StatusEditor.prototype._attach = function () {
	this.statusInput.listen("keypress", this.onkeypress.bind(this));
	this.statusInput.listen("blur", this.onInputBlur.bind(this));
	this.placeholder.listen("focus", this._onFocused.bind(this));
	var loc_anchors = DOM.scry(this.rootElem, "a.location_add_button");
	for (var i = 0; i < loc_anchors.length; i++) {
		loc_anchors[i].listen("click", this._onAddLocation.bind(this));
		show(loc_anchors[i]);
	}
	if (this.locationEnabled) {
		DOM.find(this.rootElem, "a.location_remove_button").listen("click", this._onRemoveLocation.bind(this));
	}
};
StatusEditor.prototype.onkeypress = function (event) {
	switch (event_get_keypress_keycode(event)) {
	  case KEYS.ESC:
		this.statusInput.value = this.emptyValue;
		this.statusInput.blur();
		break;
	  case KEYS.RETURN:
		this.post();
		return $E(event).kill();
	}
};
StatusEditor.prototype.onInputBlur = function () {
	var trimmed = trim(this.statusInput.value);
	if (this.isNonedit(trimmed)) {
		this.reset();
	}
};
StatusEditor.prototype.clear = function () {
	new AsyncRequest().setURI("/ajax/updatestatus.php").setData({"profile_id":this.profile_id, "clear":1}).setHandler(function () {
		this._onCleared();
		StatusEditor.update({"markup":""}, null, this);
	}.bind(this)).send();
	return false;
};
StatusEditor.prototype._onCleared = bagofholding;
StatusEditor.prototype._onFocused = bagofholding;
StatusEditor.prototype._onAddLocation = bagofholding;
StatusEditor.prototype._onRemoveLocation = bagofholding;
StatusEditor.prototype.setLocationSelector = function (selector) {
	var location_handler = function (loc) {
		if (this.location_id !== false) {
			this.location_id = loc.id;
		}
	}.bind(this);
	this._locationSelector = selector;
	selector.setLocationHandler(location_handler);
	this.locationEnabled = true;
};
StatusEditor.prototype.startEdit = function (value) {
	this.statusInput.value = value;
	this.initialValue = value;
	this.placeholder.focus();
};
StatusEditor.prototype.reset = function () {
	CSS.removeClass(this.rootElem, "placeholder_off");
	this.placeholder.getControl().setFocused(false);
};
StatusEditor.prototype.isNonedit = function (text) {
	return !text || (text == trim(this.emptyValue)) || (this.initialValue && (text == this.initialValue));
};
StatusEditor.prototype.post = function (extra_post_params) {
	var text = trim(this.statusInput.value);
	if (this.isNonedit(text)) {
		return;
	}
	this.statusInput.disabled = true;
	CSS.addClass(this.rootElem, "disabled");
	this.statusInput.blur();
	var data = {"profile_id":this.profile_id, "status":text};
	var page_uri = URI.getRequestURI();
	if (page_uri.getPath() == "/profile.php") {
		data["profile"] = true;
	} else {
		if (page_uri.getPath() == "/home.php" || page_uri.getPath() == "/widgets/livefeed.php") {
			if (window.HomeFeed) {
				var homefeed = HomeFeed.getInstance();
				if (homefeed) {
					data["home_tab_id"] = homefeed.tabId;
				}
			}
		}
	}
	if (ge("status_publish_all")) {
		data["publish_all"] = ge("status_publish_all").checked;
	}
	if (ge("post_to_profile")) {
		data["post_to_profile"] = ge("post_to_profile").checked;
	}
	if (this.app_id) {
		data["app_id"] = this.app_id;
	}
	if (this.stream_id) {
		data["live_stream_id"] = this.stream_id;
	}
	if (this.location_id) {
		data["location_id"] = this.location_id;
	}
	if (extra_post_params) {
		copy_properties(data, extra_post_params);
	}
	new AsyncRequest().setURI("/ajax/updatestatus.php").setData(data).setFinallyHandler(function () {
		this.statusInput.disabled = false;
		CSS.removeClass(this.rootElem, "disabled");
	}.bind(this)).setHandler(bind(this, handle_require_email_conf_response, function (r) {
		this.reset();
		this.initialValue = this.statusInput.value;
		var payload = r.getPayload();
		this._onPosted(payload);
		StatusEditor.update(payload, null, this);
	}.bind(this), null, null)).send();
};
StatusEditor.prototype._onPosted = bagofholding;
function HomeStatusEditor(root, profile_id) {
	this.parent.construct(this, root, profile_id);
	if (this.showsStatusBody()) {
		this.statusBody = DOM.find(root, "div.status_body");
		DOM.find(root, "a.status_clear_link").onclick = this.clear.bind(this);
	}
	this.postButton = DOM.find(root, "input[type=\"submit\"]");
	this.postButton.listen("click", this.post.shield(this));
}
HomeStatusEditor.extend("StatusEditor");
HomeStatusEditor.prototype.showsStatusBody = function () {
	return true;
};
HomeStatusEditor.prototype._onPosted = function (payload) {
	this._onUpdate(payload);
};
HomeStatusEditor.prototype._onUpdate = function (payload, time) {
	var status = payload.markup;
	if (!status) {
		this._onCleared();
	}
	if (this.showsStatusBody() && status) {
		DOM.find(this.rootElem, "span.status_text").setContent(HTML(status));
		DOM.find(this.rootElem, "span.status_time").setContent(HTML(time || _tx("a moment ago&nbsp;")));
		var status_location = DOM.scry(this.rootElem, "span.status_location")[0];
		if (!payload.location_label) {
			if (status_location) {
				hide(status_location);
			}
		} else {
			if (!status_location) {
				DOM.insertAfter(DOM.find(this.rootElem, "span.status_time"), $N("span", {className:"status_location"}, [_tx("near {location}", {location:""}), $N("a", {href:payload.location_href, target:"_blank"}, payload.location_label)]));
			}
			show(status_location);
		}
		if (CSS.hasClass(this.statusBody, "status_empty")) {
			CSS.removeClass(this.statusBody, "status_empty");
			animation(this.statusBody).to("height", "auto").from("0px").to("opacity", 1).from(0).blind().show().duration(300).ease(animation.ease.end).go();
		} else {
			animation(this.statusBody).to("opacity", 1).from(0).duration(300).go();
		}
	}
	var homefeed = window.HomeFeed && HomeFeed.getInstance();
	if (homefeed) {
		if (payload.feed) {
			var tabId = homefeed.tabId;
			if (tabId == payload.feed_tab) {
				var container = document.createElement("div");
				CSS.setClass(container, "just_updated_status");
				container.style.display = "none";
				DOM.setContent(container, HTML(payload.feed));
				var newsfeedWrapper = $("newsfeed_wrapper");
				var topStories = DOM.scry(newsfeedWrapper, "div.tab_top_stories")[0];
				newsfeedWrapper.prependContent(container);
				if (topStories && topStories.firstChild && CSS.hasClass(topStories.firstChild, "one_liner_cluster")) {
					animation(topStories.firstChild).to("padding-top", "0px").duration(300).go();
				}
				animation(container).to("height", "auto").from("0px").to("opacity", 1).from(0).blind().show().duration(300).ease(animation.ease.end).go();
			}
			homefeed.removeStoryStatusMessage();
		}
		if (payload.top_status_stories && homefeed.tabId == HomeFeed.TAB_TOP_STORIES) {
			var newsfeedWrapper = $("newsfeed_wrapper");
			var topStories = DOM.scry(newsfeedWrapper, "div.tab_top_stories")[0];
			if (topStories && topStories.firstChild && CSS.hasClass(topStories.firstChild, "one_liner_cluster")) {
				var old_status_stories = DOM.scry(topStories.firstChild, "div.status_story_wrapper");
				old_status_stories.forEach(function (story) {
					story.remove();
				});
				DOM.prependContent(topStories.firstChild, HTML(payload.top_status_stories));
			}
		}
	}
};
HomeStatusEditor.prototype._onCleared = function () {
	CSS.addClass(this.statusBody, "status_empty");
	animation(this.statusBody).to("height", "0px").to("opacity", 0).from(1).blind().hide().duration(300).ease(animation.ease.end).go();
};
HomeStatusEditor.prototype._onAddLocation = function (target) {
	CSS.addClass(this.rootElem, "location_composer_shown");
	var loc = this._locationSelector.getLocation();
	if (loc) {
		this.location_id = loc.id;
	}
	return false;
};
HomeStatusEditor.prototype._onRemoveLocation = function (target) {
	CSS.removeClass(this.rootElem, "location_composer_shown");
	this.location_id = null;
	return false;
};
function LiveFeedWidgetStatusEditor(root, profile_id) {
	this.parent.construct(this, root, profile_id);
	this.publish_line = ge("status_publish_all_line");
	this.publish_line_hover = false;
	if (this.publish_line) {
		this.publish_line.listen("mouseover", function () {
			this.publish_line_hover = true;
		}.bind(this));
		this.publish_line.listen("mouseout", function () {
			this.publish_line_hover = false;
		}.bind(this));
	}
}
LiveFeedWidgetStatusEditor.extend("HomeStatusEditor");
LiveFeedWidgetStatusEditor.prototype.showsStatusBody = function () {
	return false;
};
LiveFeedWidgetStatusEditor.prototype.setApplicationId = function (app_id) {
	this.app_id = app_id;
	return this;
};
LiveFeedWidgetStatusEditor.prototype.setStreamId = function (stream_id) {
	this.stream_id = stream_id;
	return this;
};
LiveFeedWidgetStatusEditor.prototype._onFocused = function (value) {
	this.parent._onFocused(value);
	if (this.publish_line) {
		this.publish_line.addClass("show_publish_checkbox");
	}
};
LiveFeedWidgetStatusEditor.prototype.reset = function (value) {
	if (this.publish_line_hover) {
		return;
	}
	this.parent.reset();
	if (this.publish_line) {
		this.publish_line.removeClass("show_publish_checkbox");
	}
};
LiveFeedWidgetStatusEditor.prototype.post = function () {
	var post_to_profile = true;
	var publish_all = true;
	if (ge("status_publish_all")) {
		publish_all = ge("status_publish_all").checked;
	}
	if (ge("post_to_profile")) {
		post_to_profile = ge("post_to_profile").checked;
	}
	var homefeed = HomeFeed.getInstance();
	if (homefeed) {
		homefeed.setSkipCDNTillNextStory(true);
		var tabId = homefeed.getTab();
		if (tabId == HomeFeed.TAB_LIVEWIDGET_EVERYONE && !publish_all || tabId == HomeFeed.TAB_LIVEWIDGET_FRIENDS && !post_to_profile) {
			this.showNotification();
		}
	}
	this.parent.post();
};
LiveFeedWidgetStatusEditor.prototype.showNotification = function () {
	var notificationLine = ge("status_notification_line");
	if (notificationLine) {
		animation(notificationLine).to("opacity", 1).from("opacity", 0).show().duration(1000).checkpoint().duration(3000).checkpoint().to("opacity", 0).from("opacity", 1).duration(1000).hide().go();
	}
};
LiveFeedWidgetStatusEditor.savePublishAllSetting = function (widgetAppId) {
	if (ge("status_publish_all")) {
		var publishAll = ge("status_publish_all").checked;
		new AsyncSignal("/ajax/live_feed_settings.php", {"publish_all":publishAll, "widget_app_id":widgetAppId}).send();
	}
};
LiveFeedWidgetStatusEditor.savePostToProfileSetting = function (widgetAppId) {
	if (ge("post_to_profile")) {
		var postToProfile = ge("post_to_profile").checked;
		new AsyncSignal("/ajax/live_feed_settings.php", {"post_to_profile":postToProfile, "widget_app_id":widgetAppId}).send();
	}
};
function Friends() {
}
copy_properties(Friends, {_id:0, _flid:0, _view:"everyone", _q:"", _my_friends:0, _nk:0, _nt:0, _st:0, _s:0, _p:0, _pagination:false, _from_go:false, _lists:[], _invert:{}, _friend_pages:[], _adv_init:0, _fmpt_tab:{"mutual":1, "everyone":1, "recent":1, "status":1, "phonebook":1}, _PAGE_SIZE:100, _index:true, _DEFAULT_LIST_NAME:"< " + _tx("New List") + " >", initialize:function (id, flid, view, my_friends, page_size, friend_pages, nk) {
	this._id = id;
	this._flid = flid;
	this._view = view;
	this._my_friends = my_friends;
	this._PAGE_SIZE = page_size;
	this._friend_pages = friend_pages;
	this._nk = nk;
	this._adv_init = 0, document.onselectstart = chain(document.onselectstart, Friends.select);
	PageTransitions.registerHandler(bind(Friends, "pageTransitionHandler"));
	$("friends_target").setContent(HTML(this._friend_pages[0]));
	Friends.setListsMode();
	if (my_friends) {
		Friends._hookLoadListMembership();
	}
	if (!this._flid && (this._view == "everyone" || !this._fmpt_tab[this._view])) {
		this.showAdvanced();
	}
	if (this._view == "status") {
		show("status_editor_friends");
	} else {
		hide("status_editor_friends");
	}
}, _hookLoadListMembership:function () {
	new AsyncRequest().setReadOnly(true).setMethod("GET").setURI("/friends/ajax/friends.php").setData({"membership":1}).setHandler(function (r) {
		Friends._lists = r.getPayload().lists;
		Friends._invert = r.getPayload().invert;
	}).send();
}, _hookAddToList:function (flid, uid) {
	if (lists = Friends._invert[uid]) {
		var add = true;
		for (var i = 0; i < lists.length; ++i) {
			if (lists[i] == flid) {
				add = false;
				break;
			}
		}
		if (add) {
			Friends._invert[uid].push(flid);
		}
	} else {
		Friends._invert[uid] = [flid];
	}
	Friends._hookBuildListsUI(uid);
}, _hookRemoveFromList:function (flid, uid) {
	if (lists = Friends._invert[uid]) {
		for (var i = 0; i < lists.length; ++i) {
			if (lists[i] == flid) {
				delete lists[i];
				break;
			}
		}
	}
	Friends._hookBuildListsUI(uid);
}, _hookBuildListsUI:function (uid) {
	if ((lists = Friends._invert[uid]) && (row = ge("fextlists_" + uid)) && (target = ge("fextlistsc_" + uid))) {
		var html = [];
		for (var i = 0; i < lists.length; ++i) {
			var list = lists[i];
			if (list && Friends._lists[list]) {
				html.push("<a href=\"#\" onclick=\"Friends.refreshList(" + list + ");return false;\">" + Friends._lists[list].name + "</a>" + "<a class=\"flistrm\" href=\"#\" onclick=\"Friends._removeFromList(" + uid + "," + list + ");return false;\">&nbsp;</a>" + "<br />");
			}
		}
		if (html.length) {
			target.innerHTML = html.join("");
			CSS.removeClass(row, "nolists");
		} else {
			CSS.addClass(row, "nolists");
		}
	}
}, setListsMode:function () {
	if (Friends._my_friends) {
		if ((lists = ge("frn_lists")) && (lists.childNodes.length > 2)) {
			CSS.addClass($("fpgc"), "manylists");
		} else {
			CSS.removeClass($("fpgc"), "manylists");
		}
	}
}, pageTransitionHandler:function (uri) {
	if (uri.getPath() == "/friends/") {
		var pagination;
		if (!this._from_go) {
			var params = uri.getQueryData();
			if (params.id != this._id) {
				return false;
			}
			var defaults = {flid:0, view:"everyone", q:"", nt:0, nk:0, st:0, s:0};
			pagination = true;
			for (var v in defaults) {
				params[v] = params[v] || defaults[v];
				if (v != "s" && this["_" + v] != params[v]) {
					pagination = false;
				}
				if (v == "view" || v == "q") {
					this["_" + v] = params[v];
				} else {
					this["_" + v] = parseInt(params[v]);
				}
			}
		} else {
			pagination = this._pagination;
		}
		this._refresh(pagination);
		this._pagination = false;
		this._from_go = false;
		return true;
	}
	return false;
}, toggleAdvanced:function () {
	if ($("friends_advanced").style.display == "none") {
		this.showAdvanced();
	} else {
		hide("friends_advanced");
	}
}, toggleTiny:function () {
	if (Friends._tiny) {
		CSS.removeClass($("fpgc"), "tiny");
		Friends._tiny = false;
	} else {
		Friends._tiny = true;
		CSS.addClass($("fpgc"), "tiny");
	}
}, dnd:function (e, a, id, name) {
	if (!Friends._tiny) {
		return;
	}
	Friends._dstart = Vector2.getEventPosition(e);
	Friends._did = id;
	Friends._dname = name;
	Friends._dobj = false;
	Friends._drag = true;
	Friends._dlists = $("frn_lists").getElementsByTagName("div");
	if (!Friends._dinit) {
		Friends._dinit = true;
		document.body.onmousemove = chain(document.body.onmousemove, Friends.drag);
		document.body.onmouseup = chain(document.body.onmouseup, Friends.drop);
	}
	CSS.addClass($("frn_lists"), "dragging");
	return Event.kill(e);
}, select:function (e) {
	if (Friends._drag) {
		return Event.kill(e);
	}
}, drag:function (e) {
	if (Friends._drag) {
		var pos = Vector2.getEventPosition(e);
		if (!Friends._dobj) {
			var dist = pos.distanceTo(Friends._dstart);
			if (dist > 5) {
				Friends._dobj = document.createElement("div");
				Friends._dobj.innerHTML = Friends._dname;
				CSS.setClass(Friends._dobj, "draggable_friend");
				Friends._dobj.style.top = (pos.y - 8) + "px";
				Friends._dobj.style.left = (pos.x - 8) + "px";
				var firstChild = DOM.getRootElement().firstChild;
				DOM.getRootElement().insertBefore(Friends._dobj, firstChild);
			}
		}
		if (Friends._dobj) {
			Friends._dobj.style.top = (pos.y - 8) + "px";
			Friends._dobj.style.left = (pos.x - 8) + "px";
			for (var i = 0; i < Friends._dlists.length; ++i) {
				if (Rect.getElementBounds(Friends._dlists[i]).contains(pos)) {
					CSS.addClass(Friends._dlists[i].firstChild, "hover");
				} else {
					CSS.removeClass(Friends._dlists[i].firstChild, "hover");
				}
			}
		}
	}
}, drop:function (e) {
	if (Friends._drag) {
		var end = Vector2.getEventPosition(e);
		if (Friends._dobj) {
			DOM.getRootElement().removeChild(Friends._dobj);
			for (var i = 0; i < Friends._dlists.length; ++i) {
				if (Rect.getElementBounds(Friends._dlists[i]).contains(end)) {
					Friends.dragAddList(Friends._did, Friends._dlists[i].id.slice(5));
					break;
				}
			}
		}
		Friends._dobj = false;
	}
	for (var i = 0; i < Friends._dlists.length; ++i) {
		CSS.removeClass(Friends._dlists[i].firstChild, "hover");
	}
	CSS.removeClass($("frn_lists"), "dragging");
	Friends._drag = false;
}, dragAddList:function (uid, flid) {
	if (!parseInt(flid) || (Friends._flid == flid)) {
		return;
	}
	this._showLoading();
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"add":"1", "flid":flid, "quick":1, "id":uid}).setHandler(bind(Friends, "_dragAddHandler", flid)).setErrorHandler(bind(Friends, "_dragAddError", flid)).send();
}, _dragAddHandler:function (flid, r) {
	this._hideLoading();
	Friends._dragAnimate(flid, "#77dd77");
}, _dragAddError:function (flid, r) {
	this._hideLoading();
	Friends._dragAnimate(flid, "#aa4444");
}, _dragAnimate:function (flid, start) {
	var elem = $("frni_" + flid).firstChild.nextSibling;
	animation(elem).from("color", start).to("color", "#3b5998").duration(1500).ondone(function () {
		elem.style.color = "";
	}).go();
}, phonebookSearchShow:function () {
	CSS.addClass($("friend_search_box"), "hide_search");
	CSS.removeClass($("phonebook_search_box"), "hide_search");
}, phonebookSearchHide:function () {
	CSS.addClass($("phonebook_search_box"), "hide_search");
	CSS.removeClass($("friend_search_box"), "hide_search");
}, showAdvanced:function () {
	if (this._adv_init) {
		CSS.removeClass($("friends_advanced"), "hide_advanced");
	} else {
		this._loadAdvanced(true);
	}
}, _hideAdvanced:function () {
	CSS.addClass($("friends_advanced"), "hide_advanced");
}, _loadAdvanced:function (show_on_load) {
	if (!this._adv_init) {
		if (show_on_load) {
			this._showLoading();
		}
		new AsyncRequest().setReadOnly(true).setMethod("GET").setURI("/friends/ajax/filters.php").setData({"id":this._id}).setHandler(bind(this, "_advancedHandler", show_on_load)).setErrorHandler(bind(this, "_advancedError")).send();
	}
}, _advancedHandler:function (show_on_load, r) {
	this._adv_init = 1;
	$("friends_advanced").innerHTML = r.getPayload().html;
	if (show_on_load) {
		this._hideLoading();
		this.showAdvanced();
	}
}, _advancedError:function (r) {
	this._hideLoading();
}, advancedChange:function (select) {
	var option = select.options[select.selectedIndex];
	if (option.value != "") {
		if (option.value == "---") {
			Friends._refreshPageTitle(null, _tx("Grid"));
		} else {
			Friends._refreshPageTitle(null, option.text);
		}
	}
}, _resetFilters:function () {
	if (!this._adv_init) {
		return;
	}
	this._resetNetworkTypeFilters();
	$("friends_nk").selectedIndex = 0;
	this._nk = 0;
}, _resetNetworkTypeFilters:function () {
	if (this._nt) {
		hide("friends_nt_" + this._nt);
	}
	this._nt = 0;
}, refreshList:function (flid) {
	this._resetFilters();
	this._flid = flid;
	this._s = 0;
	if (flid > 0) {
		this._view = "everyone";
	}
	this._refreshTabList(flid);
	this._go();
}, refreshView:function (view) {
	this._resetFilters();
	this._view = view;
	this._s = 0;
	if (this._view == "everyone" || !this._fmpt_tab[this._view]) {
		this._loadAdvanced(false);
	}
	this._go();
}, refreshSearch:function (query) {
	this._resetFilters();
	this._flid = 0;
	this._s = 0;
	this._view = "search";
	this._q = query;
	this._go();
}, refreshStart:function (s) {
	this._s = s;
	this._pagination = true;
	this._go();
}, filterView:function (view) {
	this._resetNetworkTypeFilters();
	this._view = view;
	this._s = 0;
	this._flid = 0;
	this._refreshPageTitle();
	this._go();
}, filterNetworkKey:function (nk, primary) {
	if (primary && this._nt) {
		hide("friends_nt_" + this._nt);
		this._nt = 0;
	}
	this._s = 0;
	this._flid = 0;
	this._nk = nk;
	this._view = "network";
	this._go();
}, filterNetworkType:function (nt) {
	this._flid = 0;
	this._nk = 0;
	this._s = 0;
	if (this._nt) {
		hide("friends_nt_" + this._nt);
	}
	this._nt = nt;
	if (nt) {
		$("friends_nt_" + nt).selectedIndex = 0;
		show("friends_nt_" + nt);
	}
	this._view = "network";
	this._go();
}, filterSocialType:function (st) {
	this._flid = 0;
	this._nk = 0;
	this._s = 0;
	if (this._nt) {
		hide("friends_nt_" + this._nt);
	}
	this._nt = 0;
	this._st = st;
	this._view = "social";
	this._go();
}, _showLoading:function () {
	if (icon = ge("friends_loading")) {
		icon.style.display = "block";
	}
}, _hideLoading:function () {
	if (icon = ge("friends_loading")) {
		icon.style.display = "none";
	}
}, _go:function () {
	this._from_go = true;
	goURI(URI.getRequestURI().setQueryData({id:this._id, flid:this._flid, view:this._view, q:this._q, nt:this._nt, nk:this._nk, s:this._s, st:this._st}));
}, _refresh:function (pagination) {
	var page = (this._s - this._p) / this._PAGE_SIZE;
	if (pagination && this._friend_pages[page]) {
		$("friends_target").scrollTop = 0;
		DOMScroll.scrollTo(new Vector2(0, 0, "document"));
		$("friends_target").setContent(HTML(this._friend_pages[page]));
		PageTransitions.transitionComplete();
	} else {
		this._index = false;
		this._showLoading();
		new AsyncRequest().setURI("/friends/ajax/friends.php").setReadOnly(true).setMethod("GET").setData({"id":this._id, "flid":this._flid, "view":this._view, "q":this._q, "nt":this._nt, "nk":this._nk, "st":this._st, "ps":this._PAGE_SIZE, "s":this._s}).setHandler(bind(this, "_refreshHandler")).setErrorHandler(bind(this, "_refreshError")).setTransportErrorHandler(bind(this, "_refreshError")).setFinallyHandler(PageTransitions.transitionComplete).send();
	}
}, _refreshTabView:function (view) {
	if (view == "search") {
		Friends._refreshPageTitle(null, _tx("Search Results"));
	} else {
		if (view != "advanced") {
			Friends._refreshPageTitle();
		}
	}
	if (!this._fmpt_tab[view]) {
		view = "everyone";
	}
	var tabIdToSelect = Tabset.getInstance("friend_pills").getFullTabId(view);
	if (tabIdToSelect != Tabset.getInstance("friend_pills").selectedId) {
		Tabset.getInstance("friend_pills").selectTab(tabIdToSelect);
	}
	if (view == "everyone" && !this._flid) {
		this.showAdvanced();
	} else {
		this._hideAdvanced();
	}
	if (view == "phonebook") {
		this.phonebookSearchShow();
	} else {
		this.phonebookSearchHide();
	}
	if (this._view == "status") {
		show("status_editor_friends");
	} else {
		hide("status_editor_friends");
	}
}, _refreshTabList:function (list) {
	if (this._my_friends) {
		var lists = $("frn_lists").getElementsByTagName("div");
		for (var i = 0; i < lists.length; ++i) {
			var elem = lists[i];
			if (elem.id == "frni_" + list) {
				this._highlightList(elem);
			} else {
				if (CSS.hasClass(elem, "active_list")) {
					this._unhighlightList(elem);
				}
			}
		}
	}
}, _refreshHandler:function (r) {
	this._p = this._s;
	this._view = r.getPayload().view;
	this._refreshTabView(this._view);
	this._refreshTabList(this._flid);
	this._friend_pages = r.getPayload().friend_pages;
	$("friends_target").scrollTop = 0;
	if (window.scroll) {
		window.scroll(0, 0);
	}
	$("friends_target").innerHTML = this._friend_pages[0];
	this._fixDeleteFooter();
	if ((editor = ge("fl_input")) && (ge("ffriends").childNodes.length == 0)) {
		editor.focus();
		CSS.setOpacity($("friends_step2"), 0);
		$("friends_step2").style.display = "block";
		animation($("friends_step2")).to("opacity", 1).duration(200).go();
	}
	if (this._my_friends) {
		this._refreshStatusSidebar();
	}
	this._hideLoading();
}, _refreshError:function (e) {
	this._hideLoading();
	goURI("/friends/?id=" + this._id);
}, _unhighlightList:function (elem) {
	CSS.removeClass(elem.childNodes[0], "active_list_a");
	CSS.removeClass(elem.childNodes[1], "active_list_a");
	CSS.removeClass(elem, "active_list");
	if (elem.nextSibling) {
		CSS.removeClass(elem.nextSibling, "prev");
	}
}, _highlightList:function (elem) {
	CSS.addClass(elem.childNodes[0], "active_list_a");
	CSS.addClass(elem.childNodes[1], "active_list_a");
	CSS.addClass(elem, "active_list");
	if (elem.nextSibling) {
		CSS.addClass(elem.nextSibling, "prev");
	}
	Friends._refreshPageTitle(elem.firstChild.nextSibling.innerHTML);
}, _fixDeleteFooter:function () {
	if (this._flid != 0) {
		if (($("ffriends").offsetHeight + 65) < $("frn_column").offsetHeight) {
			$("friends_delete").style.marginTop = $("frn_column").offsetHeight - $("ffriends").offsetHeight - 65 + "px";
		} else {
			$("friends_delete").style.marginTop = "-1px";
		}
	}
}, _refreshPageTitle:function (title, subtitle) {
	if (!Friends._my_friends) {
		return;
	}
	if (!title) {
		if (elem = ge("frni_" + this._flid)) {
			title = elem.childNodes[1].innerHTML;
		}
	}
	if (title) {
		$("friends_page_title").innerHTML = title;
		if (this._flid == 0) {
			CSS.removeClass($("friends_page_title"), "list");
			CSS.addClass($("friends_page_title"), "all");
		} else {
			CSS.removeClass($("friends_page_title"), "all");
			CSS.addClass($("friends_page_title"), "list");
		}
	}
	if (this._view == "everyone") {
		CSS.addClass($("friends_page_subtitle"), "no_title");
		return;
	}
	var newSubtitle = null;
	if ($("friends_page_subtitle")) {
		if (subtitle) {
			newSubtitle = subtitle;
		} else {
			if (this._view == "status") {
				newSubtitle = _tx("Status Updates");
			} else {
				if (this._view == "recent") {
					newSubtitle = _tx("Recently Updated");
				} else {
					if (this._view == "phonebook") {
						newSubtitle = _tx("Phonebook");
					}
				}
			}
		}
	}
	if (newSubtitle) {
		$("friends_page_subtitle").innerHTML = newSubtitle;
		CSS.removeClass($("friends_page_subtitle"), "no_title");
	}
}, _refreshStatusSidebar:function () {
	if (this._view == "status") {
		if (elem = ge("status_sidebar_feed_url")) {
			var uri = new URI(elem.href);
			uri.addQueryData({flid:this._flid});
			elem.href = uri.toString();
		}
		show("status_sidebar");
	} else {
		hide("status_sidebar");
	}
}, editList:function () {
	this._unhighlightList($("frni_" + this._flid));
	if (ge("friends_step2")) {
		hide($("friends_step2"));
	}
	hide("friends_makelist");
	CSS.setOpacity(ge("friends_step1"), 0);
	show("friends_newlist");
	animation(ge("friends_step1")).duration(200).checkpoint().to("opacity", 1).duration(200).go();
	$("friends_newlist_name").value = Friends._DEFAULT_LIST_NAME;
	$("friends_newlist_name").focus();
	$("friends_newlist_name").select();
}, editKeypress:function (e) {
	var event = e || window.event;
	var key_code = event.keyCode || event.which;
	var name = $("friends_newlist_name").value;
	if ((key_code == KEYS.RETURN) && (name == "" || name == Friends._DEFAULT_LIST_NAME)) {
		this.hideEdit();
		return false;
	}
	if (key_code == KEYS.ESC) {
		this.hideEdit();
		return false;
	}
	if ((key_code == KEYS.RETURN) && name) {
		this.hideEdit(true);
		this._createList(name);
		return true;
	}
	return true;
}, hideEdit:function (create) {
	if (!create) {
		this._highlightList($("frni_" + this._flid));
	}
	show("friends_makelist");
	hide("friends_newlist");
	return true;
}, _createList:function (name) {
	this._showLoading();
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"create":name}).setHandler(bind(Friends, "_createHandler")).setErrorHandler(bind(Friends, "_createError")).send();
}, _createHandler:function (r) {
	this._hideLoading();
	$("frn_lists").innerHTML = r.getPayload().html;
	this._view = "everyone";
	var new_flid = r.getPayload().flid;
	Friends._lists[new_flid] = {"id2":new_flid, "name":r.getPayload().name};
	Friends.refreshList(new_flid);
	Friends.setListsMode();
}, _createError:function (r) {
	this._hideLoading();
}, showDeleteListDialog:function (flid) {
	var dialog = new Dialog().setTitle(_tx("Delete List?")).setBody(_tx("Are you sure you want to delete this list? This cannot be undone.")).setButtons([Dialog.newButton("delete-list", _tx("Delete List"), "", function () {
		Friends.deleteList(flid);
		dialog.hide();
	}), Dialog.CANCEL]).show();
}, deleteList:function (flid) {
	Friends._showLoading();
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"delete":"1", "flid":flid}).setHandler(bind(Friends, "_deleteHandler")).setErrorHandler(bind(Friends, "_deleteError")).send();
}, _deleteHandler:function (r) {
	this._hideLoading();
	var flid = r.getPayload().flid;
	delete Friends._lists[flid];
	var frni = $("frni_" + flid);
	this._unhighlightList(frni);
	frni.parentNode.removeChild(frni);
	this._flid = 0;
	this.refreshList(0);
	this.setListsMode();
}, _deleteError:function (r) {
	this._hideLoading();
}, renameList:function () {
	Friends._renaming = true;
	Friends._renameHidden = false;
	Friends._rename_original = Friends._lists[this._flid].name;
	hide($("frni_" + this._flid));
	var input = $("friend_list_name_input").cloneNode(true);
	var div = document.createElement("div");
	CSS.setClass(div, "renameList");
	div.appendChild(input);
	$("frni_" + this._flid).parentNode.insertBefore(div, $("frni_" + this._flid));
	this._renameListElement = div;
	input.style.display = "block";
	input.value = Friends._rename_original;
	input.focus();
	input.select();
}, renameKeypress:function (e) {
	var event = e || window.event;
	var key_code = event.keyCode || event.which;
	var name = this._renameListElement.firstChild.value;
	if ((key_code == KEYS.RETURN) && (name == "" || (name == Friends._rename_original))) {
		Friends._renaming = false;
		this.hideRename();
		return false;
	}
	if (key_code == KEYS.ESC) {
		Friends._renaming = false;
		this.hideRename();
		return false;
	}
	if ((key_code == KEYS.RETURN) && name) {
		Friends._renaming = false;
		this.hideRename();
		this._renameList(name);
		return true;
	}
	return true;
}, blurRename:function () {
	if (Friends._renaming) {
		var new_name = this._renameListElement.firstChild.value;
		if (new_name && (new_name != Friends._rename_original)) {
			Friends._renameList(new_name);
		}
	}
	Friends._renaming = false;
	this.hideRename();
}, hideRename:function () {
	if (!Friends._renameHidden) {
		Friends._renameHidden = true;
		this._renameListElement.parentNode.removeChild(this._renameListElement);
		this._renameListElement = null;
		show($("frni_" + this._flid));
	}
	return true;
}, _renameList:function (name) {
	this._showLoading();
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"rename":name, "flid":this._flid}).setHandler(bind(Friends, "_renameHandler")).setErrorHandler(bind(Friends, "_renameError")).send();
}, _renameHandler:function (r) {
	this._hideLoading();
	var name = r.getPayload().name;
	var flid = r.getPayload().flid;
	if (this._flid == flid) {
		$("friends_page_title").innerHTML = htmlize(name);
	}
	$("frni_" + flid).childNodes[1].innerHTML = htmlize(name);
	if (Friends._lists[flid]) {
		Friends._lists[flid].name = name;
	}
}, _renameError:function (r) {
	this._hideLoading();
}, noop:function () {
	return false;
}, addToList:function (p) {
	var step2 = ge("friends_step2");
	if (step2) {
		step2.style.display = "none";
	}
	if (p && p.i) {
		Friends._showLoading();
		new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"add":"1", "flid":Friends._flid, "view":Friends._view, "id":p.i}).setHandler(bind(Friends, "_addToListHandler")).setErrorHandler(bind(Friends, "_ajaxListError")).send();
		$("fl_input").typeahead.clear();
	}
	return false;
}, _addToListHandler:function (r) {
	this._hideLoading();
	var data = r.getPayload();
	if (e = ge("f" + data.id)) {
		e.parentNode.removeChild(e);
	}
	var current = $("ffriends").innerHTML;
	$("ffriends").innerHTML = data.html + current;
	this._updateNumFriends();
	this._fixDeleteFooter();
	Friends._hookAddToList(data.flid, data.id);
}, _updateNumFriends:function () {
	if (this._friend_pages.length > 1) {
		$("summary").innerHTML = _tx("This list has been updated.");
	} else {
		var count = $("ffriends").childNodes.length;
		if (count == 0) {
			$("summary").innerHTML = _tx("This list contains no friends.");
		} else {
			if (count == 1) {
				$("summary").innerHTML = _tx("This list contains 1 friend.");
			} else {
				if (count <= this._PAGE_SIZE) {
					$("summary").innerHTML = _tx("This list contains {count} friends.", {"count":count});
				} else {
					$("summary").innerHTML = _tx("This list has been updated.");
				}
			}
		}
	}
}, remove_click:function (e, id, name, is_unreg) {
	var handle = new ContextualDialog().setClassName("remove_click").setContext(e);
	if (this._flid > 0) {
		handle.setTitle(_tx("Remove from List?")).setBody(_tx("Are you sure you want to remove {name} from this list?"), {"name":name}).setButtons([{name:"remove-from-list", label:_tx("Remove from List"), handler:Friends.removeFromList.bind(Friends, id)}, {name:"remove-from-friends", label:_tx("Remove from Friends"), handler:Friends.remove.bind(Friends, handle, id, name)}, Dialog.CANCEL]).show();
	} else {
		Friends.remove(handle, id, name, is_unreg);
	}
	return false;
}, remove:function (handle, id, name, is_unreg) {
	handle.setTitle(_tx("Remove friend?")).setBody(is_unreg ? _tx("Are you sure you want to cancel your pending friend request with {name}? He or she will not be notified.", {"name":name}) : _tx("Are you sure you want to remove {name} as a friend? This cannot be undone. {name} will not be notified.", {"name":name})).setButtons([{name:"remove-friend", label:is_unreg ? _tx("Remove Friend") : _tx("Remove Friend"), handler:function () {
		var debug = {value:this.value, trace:Util.stack(), useragent:navigator.userAgent};
		Friends._remove(id, debug);
	}}, Dialog.CANCEL]).show();
	return false;
}, _remove:function (id, debug) {
	if (!debug) {
		debug = "debug info not passed in, coming from somewhere other than remove() function";
	}
	Friends._showLoading();
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"remove_friend":"1", "view":Friends._view, "flid":Friends._flid, "id":id, "debug":debug}).setHandler(bind(Friends, "_removeHandler")).setErrorHandler(bind(Friends, "_ajaxListError")).send();
}, removeFromList:function (id) {
	Friends._removeFromList(id, Friends._flid);
}, _removeFromList:function (id, flid) {
	Friends._showLoading();
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"remove":"1", "flid":flid, "view":Friends._view, "id":id}).setHandler(bind(Friends, "_removeHandler")).setErrorHandler(bind(Friends, "_ajaxListError")).send();
}, _removeHandler:function (r) {
	this._hideLoading();
	var data = r.getPayload();
	if (data.remove_friend || (Friends._flid == data.flid)) {
		var e = ge("f" + data.id);
		if (e) {
			e.parentNode.removeChild(e);
		}
	}
	if (Friends._flid == data.flid) {
		this._updateNumFriends();
		this._fixDeleteFooter();
	}
	Friends._hookRemoveFromList(data.flid, data.id);
}, _ajaxListError:function (r) {
	this._hideLoading();
}, multiselect:function () {
	this._showLoading();
	new AsyncRequest().setURI("/friends/ajax/selector.php").setData({"flid":this._flid}).setHandler(bind(Friends, "_multiselectHandler")).setErrorHandler(bind(Friends, "_multiselectError")).send();
}, _multiselectHandler:function (r) {
	this._hideLoading();
	set_inner_html($("friends_multiselect"), r.getPayload().html);
	hide("friends_step2");
	hide("flistedit");
	show("friends_multiselect");
}, _multiselectError:function (e) {
	this._hideLoading();
}, cancelMultiselect:function () {
	hide("friends_multiselect");
	show("flistedit");
}, multiAdd:function () {
	hide("friends_multiselect");
	var ids = serialize_form($("friends_form_multiselect")).ids;
	var idstring = "";
	if (ids) {
		idstring = [];
		for (var i in ids) {
			idstring.push(ids[i]);
		}
		idstring = idstring.join(",");
	}
	this._showLoading();
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"flid":this._flid, "multiadd":"1", "ids":idstring}).setHandler(bind(Friends, "_multiaddHandler")).setErrorHandler(bind(Friends, "_multiaddError")).send();
}, _multiaddHandler:function (r) {
	this._hideLoading();
	this._view = "everyone";
	this.refreshList(r.getPayload().flid);
	Friends._hookLoadListMembership();
}, _multiaddError:function (r) {
	this._hideLoading();
}, friendClick:function (elem, event, uid) {
	if (target = $E(event).getTarget()) {
		if (DOM.isNode(target, "a") || (target.parentNode && DOM.isNode(target.parentNode, "a"))) {
			return;
		}
	}
	if (Friends._dropdown) {
		Friends._dropdown.parentNode.removeChild(Friends._dropdown);
		Friends._dropdown = null;
	} else {
		if (elem) {
			if (CSS.hasClass(elem, "click")) {
				CSS.removeClass(elem, "click");
			} else {
				if (this._my_friends) {
					Friends._hookBuildListsUI(uid);
				}
				CSS.addClass(elem, "click");
			}
		}
	}
}, bodyClick:function () {
	Friends.friendClick();
}, listDropdown:function (uid, a) {
	if (Friends._dropdown) {
		Friends._dropdown.parentNode.removeChild(Friends._dropdown);
		Friends._dropdown = null;
		return;
	}
	var pos = Vector2.getElementPosition(a);
	document.body.onclick = chain(document.body.onclick, Friends.bodyClick);
	var e = document.createElement("div");
	CSS.setClass(e, "flink_dropdown");
	e.style.left = (pos.x - 2) + "px";
	e.style.top = (pos.y - 4) + "px";
	var lists = $("frn_lists").getElementsByTagName("div");
	e.innerHTML = "<span>" + _tx("Add to list...") + "</span>";
	var inner = document.createElement("div");
	CSS.setClass(inner, "flink_inner");
	e.appendChild(inner);
	for (var i = 0; i < lists.length; ++i) {
		var list = lists[i];
		var id = parseInt(list.id.substr(5));
		if ((id > 0) && (id != Friends._flid)) {
			var link = document.createElement("a");
			inner.appendChild(link);
			var name = list.firstChild.nextSibling.innerHTML;
			link.innerHTML = name;
			link.onclick = bind(this, "dropdownAddList", uid, id, name);
		}
	}
	DOM.getRootElement().appendChild(e);
	Friends._dropdown = e;
}, dropdownAddList:function (uid, flid, name, event) {
	Event.stop(event);
	if (Friends._dropdown) {
		Friends._dropdown.innerHTML = "<span>" + _tx("Add to list...") + "</span>";
	}
	new AsyncRequest().setURI("/friends/ajax/lists.php").setData({"add":"1", "flid":flid, "quick":1, "id":uid}).setHandler(bind(Friends, "_dropdownAddHandler", flid, name)).setErrorHandler(bind(Friends, "_dropdownAddError", flid)).send();
	return false;
}, _dropdownAddHandler:function (flid, name, r) {
	Friends._hookAddToList(flid, r.getPayload().id);
	Friends._dropdownAnimate(_tx("Added to \"{list}\"", {"list":name}));
}, _dropdownAddError:function (flid, r) {
	Friends._dropdownAnimate(_tx("Sorry, an error occurred."));
}, _dropdownAnimate:function (str) {
	var e = null;
	if (e = Friends._dropdown) {
		e.innerHTML = "<span>" + _tx("Add to list...") + "</span>" + "<p>" + str + "</p>";
		animation(e).duration(750).checkpoint().to("opacity", 0).duration(750).ondone(function () {
			e.parentNode.removeChild(e);
		}).go();
	}
	Friends._dropdown = null;
}, initPref:function (value) {
	new AsyncRequest().setURI("/friends/ajax/rooster.php").setData({"pref":value}).send();
}, addExternalFriend:function () {
	return show_external_friend_dialog(null, null, "add", function () {
		Friends.refreshView("external");
	});
}, editExternalFriend:function (uid) {
	return show_external_friend_dialog(uid, null, "edit", function () {
		Friends.refreshView("external");
	});
}});
function phonebook_search_typeahead(obj, source, properties) {
	this.anchor_block = false;
	this.parent.construct(this, obj, source, properties);
}
phonebook_search_typeahead.extend("typeaheadpro");
phonebook_search_typeahead.prototype.auto_select = false;
phonebook_search_typeahead.prototype.less_than_n_chars = false;
phonebook_search_typeahead.prototype.touch_fired = false;
phonebook_search_typeahead.prototype.show = function () {
	if (!this.less_than_n_chars) {
		this.parent.show();
		this.dropdown.style.width = "137px";
	} else {
		this.hide();
	}
};
phonebook_search_typeahead.prototype.hide = function () {
	this.parent.hide();
	CSS.removeClass(ge("phonebook_search"), "typeahead_border");
};
phonebook_search_typeahead.prototype.onsubmit = function (p) {
	if (!p) {
		$("fsearch").value = $("phonebook_search").value;
		$("friend_search").submit();
		return false;
	}
};
phonebook_search_typeahead.prototype.found_suggestions = function (suggestions, text, fake_data) {
	this.parent.found_suggestions(suggestions, text, fake_data);
	if (this.list.firstChild && this.list.firstChild.firstChild) {
		CSS.addClass(this.list.firstChild.firstChild, "blue_top_border");
		CSS.removeClass(this.list, "no_border_list");
		CSS.addClass(this.list.lastChild.lastChild, "blue_bottom_border");
		CSS.addClass(ge("phonebook_search"), "typeahead_border");
	} else {
		CSS.removeClass(ge("phonebook_search"), "typeahead_border");
		CSS.removeClass(ge("phonebook_search"), "typeahead_border");
		CSS.addClass(this.list, "no_border_list");
	}
};
function phonebook_search_friend_source(get_param) {
	this.parent.construct(this, get_param);
	new AsyncRequest().setMethod("GET").setReadOnly(true).setURI("/ajax/mobile/phonebook_search.php?" + get_param).setErrorHandler(function () {
	}).setHandler(function (response) {
		this.values = response.getPayload().entries;
		this.build_index();
	}.bind(this)).setOption("nectar", false).send();
}
phonebook_search_friend_source.extend("static_source");
phonebook_search_friend_source.prototype.cache_results = true;
phonebook_search_friend_source.prototype.gen_html = function (friend, highlight) {
	var ret = ["<div>", typeahead_source.highlight_found(friend.t, highlight), "</div>"];
	if (friend.c != "") {
		ret.push("<div><small>" + _tx("M") + ": " + friend.c + "</small></div>");
	}
	if (friend.p != "") {
		ret.push("<div><small>" + _tx("O") + ": " + friend.p + "</small></div>");
	}
	if (friend.p == "" && friend.c == "") {
		ret.push("<div><small>" + _tx("Request Number") + "</small></div>");
	}
	return ret.join("");
};
phonebook_search_friend_source.prototype.search_value = function (text) {
	return this.parent.search_value(text);
};
function phonebook_search_onselect(p) {
	if (p && p.i && (p.c || p.p)) {
		goURI("/profile.php?id=" + p.i + "&v=info#contact");
		return false;
	} else {
		if (p) {
			var dialog = new Dialog().setTitle(_tx("Request Number")).setBody(_tx("Would you like to request {first-name}'s phone number?", {"first-name":p.f})).setButtons(Dialog.OK_AND_CANCEL).setHandler(confirm_handler).show();
			return false;
		}
	}
	function confirm_handler() {
		var async = new AsyncRequest();
		async.setURI("/ajax/mobile/phonebook_req.php");
		async.setData({req_id:p.i, request:"1"});
		async.setHandler(onResponse);
		async.send();
		function onResponse(asyncResponse) {
			var dialog = Dialog.getCurrentDialog();
			if (dialog) {
				dialog.hide();
			}
		}
	}
}
function phoneEditNumberKeyPress(event, phone_type) {
	keyPressed = event_get_keypress_keycode(event);
	if (keyPressed == KEYS.TAB) {
		toggleEditNumberCancel(phone_type);
		return false;
	}
	if (keyPressed == KEYS.ESC) {
		toggleEditNumberCancel(phone_type);
		return false;
	}
	if (keyPressed == KEYS.RETURN) {
		$("my_" + phone_type + "_edit_text").blur();
		return false;
	}
	return true;
}
function toggleEditNumberOn(phone_type) {
	hide("my_" + phone_type + "_text");
	hide("my_" + phone_type + "_text_number");
	hide("my_" + phone_type + "_add_link");
	hide("my_" + phone_type + "_edit_link");
	show(phone_type + "_privacy_lock");
	show("my_" + phone_type + "_edit_text");
	var editBox = $("my_" + phone_type + "_edit_text");
	editBox.selectionStart = 0;
	editBox.selectionEnd = editBox.value.length;
	editBox.focus();
}
function toggleEditNumberOff(phone_type) {
	var new_value = $("my_" + phone_type + "_text_number").innerHTML;
	hide("my_" + phone_type + "_edit_text");
	hide(phone_type + "_save_instructions");
	if (!new_value) {
		hide(phone_type + "_privacy_lock");
	}
	if (new_value) {
		show("my_" + phone_type + "_edit_link");
	} else {
		show("my_" + phone_type + "_add_link");
	}
	show("my_" + phone_type + "_text_number");
	show("my_" + phone_type + "_text");
}
function toggleEditNumberCancel(phone_type) {
	var orig_number = $("my_orig_" + phone_type + "_number").value;
	$("my_" + phone_type + "_text_number").innerHTML = orig_number;
	toggleEditNumberOff(phone_type);
	$("my_" + phone_type + "_edit_text").value = orig_number;
	$("my_" + phone_type + "_edit_text").blur();
}
function toggleEditNumberOffAndSave(phone_type) {
	$("my_" + phone_type + "_text_number").innerHTML = $("my_" + phone_type + "_edit_text").value;
	toggleEditNumberOff(phone_type);
	$("my_orig_" + phone_type + "_number").value = $("my_" + phone_type + "_edit_text").value;
	submitEditNumber($("my_" + phone_type + "_edit_text").value, phone_type);
	return true;
}
function submitEditNumber(value, phone_type) {
	if (phone_type == "mobile" || phone_type == "other_phone") {
		var data = {};
		data[phone_type] = value;
		new AsyncRequest().setURI("/ajax/mobile/updatephone.php").setMethod("POST").setData(data).send();
	}
}
if (window.Bootloader) {
	Bootloader.done(["js/7xgoudrrqhgc40go.pkg.js"]);
}

